package com.sf.ams.exception;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sf.ams.entity.Response;

/**
 * 描述：
 * 
 * <pre>HISTORY
 * ****************************************************************************
 *  ID   DATE           PERSON          REASON
 *  1    2017年10月16日      Simba.Hua         Create
 * ****************************************************************************
 * </pre>
 * @author Simba.Hua
 */
@ControllerAdvice
public class GlobalExceptionHandler {
	@ExceptionHandler(AmsException.class)
	@ResponseBody
	public Response defaultErrorHandler(HttpServletRequest request,AmsException exception){
		return new Response(Response.STATUS_FAIL,exception.getMessage());
	}
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public Response defaultErrorHandler(HttpServletRequest request,Exception exception){
		return new Response(Response.STATUS_FAIL,"后台发生异常，请联系管理员");
	}
}
